#ifndef _DB_COMMON_HPP_20120616
#define _DB_COMMON_HPP_20120616

#include <string>
#include <stdint.h>

#include "cmd_type.hpp"
using namespace cmd;

class DBCommon
{
	public :
		static std::string role_table(RID rid);

	public :
		const static int ROLE_TABLE_NUM = 64;
	
	public :
		enum DBFetchErr
		{
			E_DB_TYPE_SUCC   = 0,
			E_DB_TYPE_SMALL  = 1,
			E_DB_TYPE_MATCH  = 2,

			E_DB_FETCH_MAX
		};

		enum DBOpType
		{
			DB_OP_NONE       = 0,
			DB_OP_INSERT     = 1,
			DB_OP_DELETE     = 2,
			DB_OP_UPDATE     = 3,
			DB_OP_SELECT     = 4,
			DB_OP_COUNT      = 5,

			DB_OP_MAX
		};

		enum DBFieldType
		{
			DB_FIELD_UNKNOWN   = 0,
			DB_FIELD_INT8      = 1,
			DB_FIELD_INT16     = 2,
			DB_FIELD_INT32     = 3,
			DB_FIELD_INT64     = 4,
			DB_FIELD_STRING    = 5,
			DB_FIELD_BLOB      = 6,

			DB_FIELD_MAX
		};

	public :
		static const std::string op_type_to_str(int type);
		static const std::string field_type_to_str(int type);
		static const std::string fetch_err_to_str(int err_code);
};

#endif

